package com.zhss.dfs.datanode.server;

/**
 * @author: 周成龙
 * @date: 2021/1/27 20:04
 * @description:
 */
public class DataNode extends DataNodeInfo{

    /**
     * 系统阿会否运行的标志位
     */
    private volatile boolean isRunning=true;

    private static final Long CHECK_SERVICE_ALIVE_INTERVAL=10*1000L;
    /**
     * 负责对一组NameNode通讯的组件
     */
    private NameNodeGroupOfferService offerService;

    public DataNode(String IP, String port, String dataNodeName) {
        super(IP, port, dataNodeName);
    }

    /**
     * 初始化DataNode
     */
    private void initialize() {
        this.isRunning=true;
        offerService=new NameNodeGroupOfferService();
        offerService.start(this);
    }

    /**
     *运行DataNode
     */
    private void run() {
        while (isRunning){
            try {
                Thread.sleep(DataNode.CHECK_SERVICE_ALIVE_INTERVAL);
            }catch (Exception e){
                System.out.println(e.toString());
            }
        }
    }
    public static void main(String[] args) {
        long l = System.currentTimeMillis();
        DataNode dataNode=new DataNode("106.14.140.211","6379","firstDataNode");
        dataNode.initialize();
        long l1 = System.currentTimeMillis();
        System.out.println(l1-l);
        dataNode.run();
    }


}
